﻿using UnityEngine;

namespace CWM.Skinn
{
    public static partial class SkinnContextCommands
    {
        [CtxMenuItem("Renderer/Clipboard/Copy",
            "Stores Renderer for Pasting Commands",
            ContextRequirements.SingleItem, 0)]
        public static void RendererCopy()
        {
            var item = SkinnContext.GetContextItem();

            if (SkinnInternalAsset.DevLog)
            {
                var log = string.Format("GetContextItem {0}", item.name);
                Debug.Log(log);
            }

            if (!item) { SkinnContext.Finished(); return; }
            var context = item.GetComponent<Renderer>();
            if (!SkinnEx.HasSharedMesh(context)) { SkinnContext.Finished(); return; }
            SkinnContext.CopyRef.Asset = context;
            SkinnContext.Finished();

            if (SkinnInternalAsset.DevLog)
            {
                var log = string.Format("Clipboard Copied: {0}", context.gameObject.name);
                Debug.Log(log);
            }
        }
    }
}